/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.settlement.entity.customercarcontract;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import com.jeesite.modules.settlement.entity.customersettlement.CustomerSettlement;
import com.jeesite.modules.sys.entity.Company;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 客户汽车供需合同Entity
 *
 * @author LV
 * @version 2021-03-06
 */
@Table(name = "t_customer_car_contract", alias = "a", columns = {
        @Column(name = "customer_car_contract_id", attrName = "customerCarContractId", label = "客户汽车供需合同ID", isPK = true),
        @Column(name = "customer_car_contract_code", attrName = "customerCarContractCode", label = "编号", queryType = QueryType.LIKE),
        @Column(name = "service_order_id", attrName = "serviceOrderId", label = "服务订单"),
        @Column(name = "customer_id", attrName = "customerId", label = "客户"),
        @Column(name = "customer_settlement_id", attrName = "customerSettlementId", label = "客户结算单id"),
        @Column(name = "company_id", attrName = "company.companyCode", label = "代理公司"),
        @Column(name = "date", attrName = "date", label = "订单日期"),
        @Column(name = "invoice_customer_id", attrName = "invoiceCustomerId", label = "开票客户"),
        @Column(name = "remarks", attrName = "remarks", label = "备注信息", queryType = QueryType.LIKE),
        @Column(name = "create_by", attrName = "createBy", label = "创建者", isUpdate = false),
        @Column(name = "create_date", attrName = "createDate", label = "创建时间", isUpdate = false),
        @Column(name = "update_by", attrName = "updateBy", label = "更新者", isQuery = false),
        @Column(name = "update_date", attrName = "updateDate", label = "更新时间", isQuery = false),
}, joinTable = {
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Company.class, attrName = "company", alias = "b",
                on = "b.company_code = a.company_id", columns = {
                @Column(name = "company_code", label = "公司编码", isPK = true),
                @Column(name = "company_name", label = "公司名称", isQuery = false),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Customer.class, attrName = "customer", alias = "c",
                on = "c.customer_id = a.customer_id", columns = {
                @Column(name = "customer_id", label = "客户编号", isPK = true),
                @Column(name = "customer_name", label = "客户名称"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Customer.class, attrName = "invoiceCustomer", alias = "d",
                on = "d.customer_id = a.invoice_customer_id", columns = {
                @Column(name = "customer_id", label = "客户编号", isPK = true),
                @Column(name = "customer_name", label = "客户名称"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "e",
                on = "e.service_order_id = a.service_order_id",
                columns = {
                        @Column(name = "service_order_id", label = "服务订单ID", isPK = true),
                        @Column(name = "service_order_code", label = "服务订单编号"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = CustomerSettlement.class, attrName = "customerSettlement", alias = "f",
                on = "f.customer_settlement_id = a.customer_settlement_id", columns = {
                @Column(name = "customer_settlement_id", label = "客户结算编号", isPK = true),
                @Column(name = "customer_settlement_code", label = "客户结算名称"),
        }),

}, orderBy = "a.update_date DESC"
)
public class CustomerCarContract extends DataEntity<CustomerCarContract> {

    private static final long serialVersionUID = 1L;
    private String customerCarContractId;        // 客户汽车供需合同ID
    private String customerCarContractCode;        // 编号
    private String serviceOrderId;        // 服务订单
    private ServiceOrder serviceOrder;        // 服务订单
    private String customerId;        // 客户
    private String customerSettlementId;        // 客户结算
    private Customer customer;        // 客户
    private String companyId;        // 代理公司
    private Company company;        // 代理公司
    private Date date;        // 订单日期
    private String invoiceCustomerId;        // 开票客户
    private Customer invoiceCustomer;        // 开票客户
    private CustomerSettlement customerSettlement;
    private List<CustomerCarContractDetail> customerCarContractDetailList = ListUtils.newArrayList();        // 子表列表

    public CustomerCarContract() {
        this(null);
    }

    public CustomerCarContract(String id) {
        super(id);
    }

    public String getCustomerCarContractId() {
        return customerCarContractId;
    }

    public void setCustomerCarContractId(String customerCarContractId) {
        this.customerCarContractId = customerCarContractId;
    }

    @Length(min = 0, max = 100, message = "编号长度不能超过 100 个字符")
    public String getCustomerCarContractCode() {
        return customerCarContractCode;
    }

    public void setCustomerCarContractCode(String customerCarContractCode) {
        this.customerCarContractCode = customerCarContractCode;
    }

    @Length(min = 0, max = 64, message = "服务订单长度不能超过 64 个字符")
    public String getServiceOrderId() {
        return serviceOrderId;
    }

    public void setServiceOrderId(String serviceOrderId) {
        this.serviceOrderId = serviceOrderId;
    }

    @Length(min = 0, max = 64, message = "客户长度不能超过 64 个字符")
    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    @Length(min = 0, max = 64, message = "代理公司长度不能超过 64 个字符")
    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @NotNull(message = "订单日期不能为空")
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @Length(min = 0, max = 64, message = "开票客户长度不能超过 64 个字符")
    public String getInvoiceCustomerId() {
        return invoiceCustomerId;
    }

    public void setInvoiceCustomerId(String invoiceCustomerId) {
        this.invoiceCustomerId = invoiceCustomerId;
    }

    public Date getDate_gte() {
        return sqlMap.getWhere().getValue("date", QueryType.GTE);
    }

    public void setDate_gte(Date date) {
        sqlMap.getWhere().and("date", QueryType.GTE, date);
    }

    public Date getDate_lte() {
        return sqlMap.getWhere().getValue("date", QueryType.LTE);
    }

    public void setDate_lte(Date date) {
        sqlMap.getWhere().and("date", QueryType.LTE, date);
    }

    public Date getCreateDate_gte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
    }

    public void setCreateDate_gte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
    }

    public Date getCreateDate_lte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
    }

    public void setCreateDate_lte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
    }

    public List<CustomerCarContractDetail> getCustomerCarContractDetailList() {
        return customerCarContractDetailList;
    }

    public void setCustomerCarContractDetailList(List<CustomerCarContractDetail> customerCarContractDetailList) {
        this.customerCarContractDetailList = customerCarContractDetailList;
    }

    public ServiceOrder getServiceOrder() {
        return serviceOrder;
    }

    public void setServiceOrder(ServiceOrder serviceOrder) {
        this.serviceOrder = serviceOrder;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    public Customer getInvoiceCustomer() {
        return invoiceCustomer;
    }

    public void setInvoiceCustomer(Customer invoiceCustomer) {
        this.invoiceCustomer = invoiceCustomer;
    }

    public String getCustomerSettlementId() {
        return customerSettlementId;
    }

    public void setCustomerSettlementId(String customerSettlementId) {
        this.customerSettlementId = customerSettlementId;
    }

    public CustomerSettlement getCustomerSettlement() {
        return customerSettlement;
    }

    public void setCustomerSettlement(CustomerSettlement customerSettlement) {
        this.customerSettlement = customerSettlement;
    }
}